package org.kumas.sgrpc.common.extension.adaptive;

import org.kumas.sgrpc.common.URL;
import org.kumas.sgrpc.common.extension.ExtensionLoader;

/**
 * @author KumasZhang
 * @version 1.0
 * @since 2021-07-09 09:22
 */
public class HasAdaptiveExt$Adaptive implements HasAdaptiveExt {
    @Override
    public String echo(URL url, String s) {
        if (url == null) throw new IllegalArgumentException("url == null");

        String extName = url.getParameter("has.adaptive.ext", "adaptive");
        if(extName == null) throw new IllegalStateException("Failed to get extension (org.apache.dubbo.common.extension.adaptive.HasAdaptiveExt) name from url (" + url.toString() + ") use keys([has.adaptive.ext])");
        HasAdaptiveExt extension = (HasAdaptiveExt) ExtensionLoader.getExtensionLoader(HasAdaptiveExt.class).getExtension(extName);
        return extension.echo(url, s);
    }

}
